package com.powernode.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.powernode.domain.Prod;
import com.powernode.service.SearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "搜索服务接口管理")
@RestController
@RequestMapping
public class SearchController {

    @Autowired
    private SearchService searchService;

    @ApiOperation("搜索标签分页列表")
    @GetMapping("/prod/prodListByTagId")
    public ResponseEntity<Page<Prod>> prodListByTagId(@RequestParam("tagId") Long tagId
            , @RequestParam("size") Integer size) {
        Page<Prod> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(1, size);
        List<Prod> result = searchService.prodListByTagId(tagId, size);
        page.setRecords(result);
        return ResponseEntity.ok(page);
    }
}
